package com.qilu.pe.dao.http;

import com.qilu.pe.base.Config;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

public class APIRetrofit {
    private static ApiService SERVICE;

    public static ApiService getDefault() {
        if (SERVICE == null) {

            SERVICE = new Retrofit.Builder()
//                    .baseUrl(Constant.RETROFIT_URL)
                    .baseUrl(Config.URL)
                    .addConverterFactory(GsonConverterFactory.create())
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .client(Config.getClient())
                    .build().create(ApiService.class);
        }
        return SERVICE;
    }

    private static ApiService SERVICE_LS;

    public static ApiService getLs() {
        if (SERVICE_LS == null) {

            SERVICE_LS = new Retrofit.Builder()
//                    .baseUrl(URL_LS.RETROFIT_URL)
                    .baseUrl(Config.URL_LS)
                    .addConverterFactory(GsonConverterFactory.create())
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .client(Config.getClient())
                    .build().create(ApiService.class);
        }
        return SERVICE_LS;
    }
}
